/*
 * Copyright (c) 2016 zhangcm. All Rights Reserved.
 */
package com.jnzc.ocr.serv.shop.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.jnzc.ocr.common.utils.BusinessUtils;
import com.jnzc.ocr.common.utils.DateUtils;
import com.jnzc.ocr.common.utils.ValidateUtils;
import com.jnzc.ocr.dependencies.serv.mybatis.MybatisServiceImpl;
import com.jnzc.ocr.serv.shop.entity.ShopMain;
import com.jnzc.ocr.serv.shop.filter.ShopMainFilter;
import com.jnzc.ocr.serv.shop.mapper.ShopMainMapper;
import com.jnzc.ocr.serv.shop.service.ShopMainService;
import com.jnzc.ocr.serv.system.api.SysNoApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhangcm
 * @version 1.0, 2017/8/31
 */
@Service
public class ShopMainServiceImpl extends MybatisServiceImpl<ShopMainMapper, ShopMain, ShopMainFilter> implements ShopMainService {

    @Autowired
    private ShopMainMapper shopMainMapper;

    @Override
    protected void fillEntityWrapper(EntityWrapper<ShopMain> ew, ShopMainFilter filter) {
        ShopMain entity = new ShopMain();
        entity.setId(filter.getId());
        entity.setCompanyId(filter.getCompanyId());
        ew.setEntity(entity);
    }

    @Override
    public ShopMain find(Long id) {
        ValidateUtils.isId(id, "店铺ID");
        ShopMain obj = shopMainMapper.selectById(id);
        BusinessUtils.notNull(obj, "店铺信息不存在");
        return obj;
    }

    @Override
    public List<ShopMain> listByCompanyId(Long companyId) {
        ShopMainFilter filter = new ShopMainFilter();
        filter.setCompanyId(companyId);
        return super.list(filter);
    }
}
